function newsupdate_opacity(newsupdate_instanceid, opacity) { 
	
	if(opacity < 0)
		opacity = 0;
	else if(opacity > 100)
		opacity = 100;
	
    var container_style = document.getElementById(newsupdate_instanceid).style; 
    container_style.opacity = (opacity / 100); 
    container_style.MozOpacity = (opacity / 100); 
    container_style.KhtmlOpacity = (opacity / 100); 
    container_style.filter = "alpha(opacity=" + opacity + ")"; 
}

function newsupdate_getchildbyID(newsupdate_element, element_ID)
{
	if(newsupdate_element) {
		for(var i = 0; i < newsupdate_element.childNodes.length; i++) {
			if(element_ID == newsupdate_element.childNodes[i].id)
				return newsupdate_element.childNodes[i];
		}
	}
	return null;
}
var newsupdate_messages = null;
var newsupdate_images = null;
var newsupdate_imageopacity = 0.0;
var newsupdate_sliderposition = 0.0;
var newsupdate_imagefile_index = 1;
var newsupdate_message_index = 0;

function newsupdate_onUpdate(newsupdate_instanceid)
{	
	var slideDiv = newsupdate_getchildbyID(document.getElementById(newsupdate_instanceid), "update_slider");
	var containerDiv = newsupdate_getchildbyID(slideDiv, "slider_container");
	containerDiv.style.top = (newsupdate_sliderposition) + "px";
	containerDiv.innerHTML = newsupdate_messages[newsupdate_message_index];
	if(parseInt(containerDiv.style.top) > parseInt(containerDiv.style.height)) {
		newsupdate_sliderposition = -parseInt(containerDiv.style.height);
		newsupdate_message_index += 1;
		if(newsupdate_message_index > newsupdate_messages.length - 1) 
			newsupdate_message_index = 0;
	}
	else{
		newsupdate_sliderposition += 0.15;
	}
	
	var imageURL = newsupdate_images[newsupdate_imagefile_index];// "mysource_files/update_"+ newsupdate_imagefile_index+ ".jpg";
	var imagesDiv = newsupdate_getchildbyID(document.getElementById(newsupdate_instanceid), "update_images");
	var imageOpacity = ((Math.sin(newsupdate_imageopacity) * 0.5) + 0.5) * 100.0;

	if(imageOpacity > 90){
		
		newsupdate_imageopacity += (0.0025 * (1.0 / Math.PI));
		
	}
	else{
	
		var prevPos = newsupdate_imageopacity;
		newsupdate_imageopacity += (0.25 * (1.0 / Math.PI));
		var nextOpacity = ((Math.sin(newsupdate_imageopacity) * 0.5) + 0.5) * 100.0;
		if(imageOpacity <= 1 && nextOpacity > 1) {
			newsupdate_imagefile_index ++;
			if(newsupdate_imagefile_index > newsupdate_images.length - 1)
				newsupdate_imagefile_index = 0;	
		}
	}

	newsupdate_opacity(imagesDiv.id, imageOpacity);
	imagesDiv.style.backgroundImage = "url(" + imageURL + ")";

	setTimeout('newsupdate_onUpdate(\'' + newsupdate_instanceid + '\')', 15);
}

function newsupdate(divTarget, update_messages, update_images)
{

	newsupdate_messages = update_messages;
	newsupdate_images = update_images;
	this._divImages = newsupdate_getchildbyID(divTarget, "update_images");
	this._divSlider = newsupdate_getchildbyID(divTarget, "update_slider");	
	this._divTarget = divTarget;
	setTimeout('newsupdate_onUpdate(\'' + this._divTarget.id + '\')', 25);
}

